home *** CD-ROM | disk | FTP | other *** search
-
- /* --------------------------------------------------------------
-
- FUNCTION LOCATE_NODE: The steps to locating a node in the list are:
-
- A. Make one cycle of the list starting at the root. Since process idle
- has priority zero and the user cannot add nodes with a priority less
- than 1, the idle node is always the last one in the cycle.
-
- B. If the priority we are searching for is equal to the current
- entry's, return the previous entry's address.
-
- C. Else if the new priority is greater than that in the list the one we
- are searching for isn't in the list. So is we were looking for
- an exact match indicate it wasn't found. For an inexact match
- return the address of the previous node (which must be greater than
- the one we are searching for).
-
- D. The match may still be coming so keep looking.
-
- E. We've reached the end of the list so is we were looking for
- an exact match indicate it wasn't found. For an inexact match
- return the address of the previous node (which must be greater than
- the one we are searching for).
-
- -------------------------------------------------------------- */
-
- Node *locate_node(unsigned priority, int match)
- {
- const Node *pnode = proot_node;
-
- /*A*/ while (pnode->process != idle) {
- /*B*/ if (priority == pnode->priority) {
- return pnode->pbwd;
- }
- /*C*/ else if (priority > pnode->priority) {
- if (match == EXACT) {
- return NULL;
- }
- else {
- return pnode->pbwd;
- }
- }
- /*D*/ else {
- pnode = pnode->pfwd;
- }
- }
-
- /*E*/ if (match == EXACT) {
- return NULL;
- }
- else {
- return pnode->pbwd;
- }
- }
-
-